/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Personal.java
 *
 * Created on 22/11/2011, 01:15:27 AM
 */
package Interface;

import Dominio.Controladora;
import java.awt.event.MouseEvent;
import javax.swing.JOptionPane;
import javax.swing.JTable;

/**
 *
 * @author Agustin
 */
public class Personal extends javax.swing.JFrame {

    private static Personal instance;

    public static Personal getInstance() {
        if (instance == null) {
            instance = new Personal();
        }
        instance.limpiar();
        return instance;
    }

    /** Creates new form Personal */
    public Personal() {
        initComponents();
        setEventoMouseClickedUsuarios();
        this.setLocationRelativeTo(null);
        setEventoMouseClickedUsuarioMasCalificado();
        setEventoMouseClickedEmpleados();
        setEventoMouseClickedUsuarioMasCotizado();

        limpiar();
    }

    private void setEventoMouseClickedUsuarios() {

        tblUsuarios.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                tblUsuariosMouseClicked(e);
            }
        });
    }

    private void tblUsuariosMouseClicked(java.awt.event.MouseEvent evt) {
        int row = this.tblUsuarios.rowAtPoint(evt.getPoint());
        if (row >= 0 && tblUsuarios.isEnabled()) {
            if (tblUsuarios.getModel().getValueAt(row, 0) != null) {
                txtNombreUsuario.setText(tblUsuarios.getModel().getValueAt(row, 0).toString());

            }
        }

    }

    private void setEventoMouseClickedEmpleados() {

        tblEpleados.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                tblEmpleadosMouseClicked(e);
            }
        });
    }

    private void tblEmpleadosMouseClicked(java.awt.event.MouseEvent evt) {
        int row = this.tblEpleados.rowAtPoint(evt.getPoint());
        if (row >= 0 && tblEpleados.isEnabled()) {
            if (tblEpleados.getModel().getValueAt(row, 0) != null) {
                txtNombreUsuario.setText(tblEpleados.getModel().getValueAt(row, 0).toString());
            }
        }

    }

    private void setEventoMouseClickedUsuarioMasCalificado() {

        tblUsuarioMasCalificado.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                tblUsuarioMasCalificadoMouseClicked(e);
            }
        });
    }

    private void tblUsuarioMasCalificadoMouseClicked(java.awt.event.MouseEvent evt) {
        int row = this.tblUsuarioMasCalificado.rowAtPoint(evt.getPoint());
        if (row >= 0 && tblUsuarioMasCalificado.isEnabled()) {
            if (tblUsuarioMasCalificado.getModel().getValueAt(row, 0) != null) {
                txtNombreUsuario.setText(tblUsuarioMasCalificado.getModel().getValueAt(row, 0).toString());
            }
        }

    }

    private void setEventoMouseClickedUsuarioMasCotizado() {

        tblUsuarioMasCotizado.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                tblUsuarioMasCotizadoMouseClicked(e);
            }
        });
    }

    private void tblUsuarioMasCotizadoMouseClicked(java.awt.event.MouseEvent evt) {
        int row = this.tblUsuarioMasCotizado.rowAtPoint(evt.getPoint());
        if (row >= 0 && tblUsuarioMasCotizado.isEnabled()) {
            if (tblUsuarioMasCotizado.getModel().getValueAt(row, 0) != null) {
                txtNombreUsuario.setText(tblUsuarioMasCotizado.getModel().getValueAt(row, 0).toString());
            }
        }

    }

    public void limpiar() {
        try {
            ModeloComboEspecialidades m = new ModeloComboEspecialidades();
            cmbEspecialidad.setModel(m);

            ModeloTablaUsuarios emp = new ModeloTablaUsuarios(1, "", 0);
            JTable empleados = new JTable(emp.getUsuarios(), emp.getCabeceras());
            tblEpleados.setModel(empleados.getModel());

            ModeloTablaUsuarios noemp = new ModeloTablaUsuarios(2, "", 0);
            JTable noempleados = new JTable(noemp.getUsuarios(), noemp.getCabeceras());
            tblUsuarios.setModel(noempleados.getModel());

            ModeloTablaUsuarios usuMasCalificado = new ModeloTablaUsuarios(3, "", 0);
            JTable usuarioMasCalificado = new JTable(usuMasCalificado.getUsuarios(), usuMasCalificado.getCabeceras());
            tblUsuarioMasCalificado.setModel(usuarioMasCalificado.getModel());

            ModeloTablaUsuarios usuMasCotizado = new ModeloTablaUsuarios(4, "", 0);
            JTable usuarioMasCotizado = new JTable(usuMasCotizado.getUsuarios(), usuMasCotizado.getCabeceras());
            tblUsuarioMasCotizado.setModel(usuarioMasCotizado.getModel());

            txtNombreUsuario.setText("");
            txtComentario.setText("");
            txtVHU.setText("");
        } catch (Exception e) {
            System.out.println(e.toString());
            throw new UnsupportedOperationException(e.toString());
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblPersonal = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblUsuarios = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblUsuarioMasCalificado = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblUsuarioMasCotizado = new javax.swing.JTable();
        lblUsuarioMasCalificado = new javax.swing.JLabel();
        lblUsuario = new javax.swing.JLabel();
        lblUsuarioMasCotizado1 = new javax.swing.JLabel();
        lblCalificacion = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tblEpleados = new javax.swing.JTable();
        lblUsuario1 = new javax.swing.JLabel();
        btnCalificar = new javax.swing.JButton();
        rbtnPositivo = new javax.swing.JRadioButton();
        rbtnNegativo = new javax.swing.JRadioButton();
        lblNombreUsuario1 = new javax.swing.JLabel();
        txtComentario = new javax.swing.JTextField();
        lblComentario = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tblSujerencias = new javax.swing.JTable();
        lblSujerencias = new javax.swing.JLabel();
        cmbEspecialidad = new javax.swing.JComboBox();
        lblEspecialidad = new javax.swing.JLabel();
        txtVHU = new javax.swing.JTextField();
        lblVHU = new javax.swing.JLabel();
        lblNombreUsuario = new javax.swing.JLabel();
        txtNombreUsuario = new javax.swing.JTextField();
        btnAgregarEmpleado = new javax.swing.JButton();
        btnDejarEmpleado = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        lblPersonal.setFont(new java.awt.Font("Monospaced", 0, 24));
        lblPersonal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblPersonal.setText("Personal");

        tblUsuarios.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(tblUsuarios);

        tblUsuarioMasCalificado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane2.setViewportView(tblUsuarioMasCalificado);

        tblUsuarioMasCotizado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane3.setViewportView(tblUsuarioMasCotizado);

        lblUsuarioMasCalificado.setText("Usuario Mas Calificado");

        lblUsuario.setText("Usuarios");

        lblUsuarioMasCotizado1.setText("Usuario Mas Cotizado");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblUsuarioMasCalificado)
                .addContainerGap(433, Short.MAX_VALUE))
            .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblUsuarioMasCotizado1)
                .addContainerGap(437, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblUsuario)
                .addContainerGap(499, Short.MAX_VALUE))
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(lblUsuarioMasCalificado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(lblUsuarioMasCotizado1)
                .addGap(11, 11, 11)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(lblUsuario)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Usuarios", jPanel1);

        tblEpleados.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane4.setViewportView(tblEpleados);

        lblUsuario1.setText("Empleados");

        btnCalificar.setText("c");
        btnCalificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCalificarActionPerformed(evt);
            }
        });

        rbtnPositivo.setText("Psitivo");
        rbtnPositivo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                rbtnPositivoItemStateChanged(evt);
            }
        });

        rbtnNegativo.setText("Negativo");
        rbtnNegativo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                rbtnNegativoItemStateChanged(evt);
            }
        });

        lblNombreUsuario1.setText("Calificacion");

        lblComentario.setText("Comentario");

        javax.swing.GroupLayout lblCalificacionLayout = new javax.swing.GroupLayout(lblCalificacion);
        lblCalificacion.setLayout(lblCalificacionLayout);
        lblCalificacionLayout.setHorizontalGroup(
            lblCalificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lblCalificacionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(lblCalificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, lblCalificacionLayout.createSequentialGroup()
                        .addComponent(lblComentario)
                        .addGap(18, 18, 18)
                        .addComponent(txtComentario))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, lblCalificacionLayout.createSequentialGroup()
                        .addComponent(lblNombreUsuario1)
                        .addGap(18, 18, 18)
                        .addComponent(rbtnPositivo)
                        .addGap(18, 18, 18)
                        .addComponent(rbtnNegativo)))
                .addGap(18, 18, 18)
                .addComponent(btnCalificar)
                .addGap(85, 85, 85))
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
            .addGroup(lblCalificacionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblUsuario1)
                .addContainerGap(489, Short.MAX_VALUE))
        );
        lblCalificacionLayout.setVerticalGroup(
            lblCalificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lblCalificacionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(lblCalificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNombreUsuario1)
                    .addComponent(rbtnPositivo)
                    .addComponent(rbtnNegativo)
                    .addComponent(btnCalificar))
                .addGap(18, 18, 18)
                .addGroup(lblCalificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblComentario)
                    .addComponent(txtComentario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addComponent(lblUsuario1)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jTabbedPane1.addTab("Empleados", lblCalificacion);

        tblSujerencias.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane5.setViewportView(tblSujerencias);

        lblSujerencias.setText("Sujerencias");

        lblEspecialidad.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblEspecialidad.setText("Especialidad");

        txtVHU.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtVHUFocusLost(evt);
            }
        });

        lblVHU.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblVHU.setText("VHU");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblEspecialidad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
                    .addComponent(cmbEspecialidad, 0, 375, Short.MAX_VALUE))
                .addGap(45, 45, 45)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(txtVHU)
                    .addComponent(lblVHU, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblSujerencias)
                .addContainerGap(485, Short.MAX_VALUE))
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEspecialidad)
                    .addComponent(lblVHU))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbEspecialidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtVHU, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(lblSujerencias)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Mejor Combinacion", jPanel2);

        lblNombreUsuario.setText("Nombre Usuario");

        btnAgregarEmpleado.setText("+");
        btnAgregarEmpleado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarEmpleadoActionPerformed(evt);
            }
        });

        btnDejarEmpleado.setText("-");
        btnDejarEmpleado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDejarEmpleadoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblPersonal, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(lblNombreUsuario)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtNombreUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(btnAgregarEmpleado)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnDejarEmpleado)
                        .addGap(12, 12, 12))
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblPersonal)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAgregarEmpleado)
                    .addComponent(txtNombreUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDejarEmpleado, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNombreUsuario))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 421, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAgregarEmpleadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarEmpleadoActionPerformed
        try {
            int i = Controladora.getInstance().agregarEmpleado(Controladora.getInstance().getEmpresa().getRut() + "", txtNombreUsuario.getText().toString().trim());
            if (i == 0) {
                JOptionPane.showMessageDialog(this, "El empleado se ha agregado correctamente", "Listo", JOptionPane.INFORMATION_MESSAGE);
                limpiar();
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, Controladora.getInstance().limpiarE(e), "Atencion", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btnAgregarEmpleadoActionPerformed

    private void btnCalificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCalificarActionPerformed
        try {
            int x = 0;
            if (rbtnPositivo.isSelected()) {
                x = 1;
            }
            if (rbtnNegativo.isSelected()) {
                x = -1;
            }
            Controladora.getInstance().calificarEmpleados(txtNombreUsuario.getText().trim(), x + "", txtComentario.getText().trim());
            JOptionPane.showMessageDialog(this, "Calificacion correcta", "Listo", JOptionPane.INFORMATION_MESSAGE);
            limpiar();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, Controladora.getInstance().limpiarE(e), "Atencion", JOptionPane.ERROR_MESSAGE);
        }


    }//GEN-LAST:event_btnCalificarActionPerformed

    private void rbtnPositivoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbtnPositivoItemStateChanged
        if (rbtnPositivo.isSelected()) {
            rbtnNegativo.setEnabled(false);
        } else {
            rbtnNegativo.setEnabled(true);
        }
    }//GEN-LAST:event_rbtnPositivoItemStateChanged

    private void rbtnNegativoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbtnNegativoItemStateChanged
        if (rbtnNegativo.isSelected()) {
            rbtnPositivo.setEnabled(false);
        } else {
            rbtnPositivo.setEnabled(true);
        }
    }//GEN-LAST:event_rbtnNegativoItemStateChanged

    private void btnDejarEmpleadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDejarEmpleadoActionPerformed
        try {
            Controladora.getInstance().dejarUsuario(txtNombreUsuario.getText(), Controladora.getInstance().getEmpresa().getRut() + "");
            JOptionPane.showMessageDialog(this, "Ha dejado correctamente al Empleado", "Listo", JOptionPane.INFORMATION_MESSAGE);
            limpiar();

        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, Controladora.getInstance().limpiarE(e), "Atencion", JOptionPane.ERROR_MESSAGE);
        }


    }//GEN-LAST:event_btnDejarEmpleadoActionPerformed

    private void txtVHUFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtVHUFocusLost
        try {
            if (cmbEspecialidad.getSelectedItem() != null) {
                if (!txtVHU.getText().equals("")) {
                    if (Controladora.getInstance().isNumeric(txtVHU.getText())) {
                        ModeloTablaUsuarios sujerencias = new ModeloTablaUsuarios(6, cmbEspecialidad.getSelectedItem().toString(), Integer.parseInt(txtVHU.getText()));
                        JTable sujeridos = new JTable(sujerencias.getUsuarios(), sujerencias.getCabeceras());
                        tblSujerencias.setModel(sujeridos.getModel());
                    } else {
                        throw new Exception("El VHU debe ser numerico.");
                    }
                } else {
                    throw new Exception("El VHU no puede ser vacio.");
                }
            } else {
                throw new Exception("Debe elegir una especialidad.");
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, Controladora.getInstance().limpiarE(e), "Error", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_txtVHUFocusLost

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Personal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregarEmpleado;
    private javax.swing.JButton btnCalificar;
    private javax.swing.JButton btnDejarEmpleado;
    private javax.swing.JComboBox cmbEspecialidad;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel lblCalificacion;
    private javax.swing.JLabel lblComentario;
    private javax.swing.JLabel lblEspecialidad;
    private javax.swing.JLabel lblNombreUsuario;
    private javax.swing.JLabel lblNombreUsuario1;
    private javax.swing.JLabel lblPersonal;
    private javax.swing.JLabel lblSujerencias;
    private javax.swing.JLabel lblUsuario;
    private javax.swing.JLabel lblUsuario1;
    private javax.swing.JLabel lblUsuarioMasCalificado;
    private javax.swing.JLabel lblUsuarioMasCotizado1;
    private javax.swing.JLabel lblVHU;
    private javax.swing.JRadioButton rbtnNegativo;
    private javax.swing.JRadioButton rbtnPositivo;
    private javax.swing.JTable tblEpleados;
    private javax.swing.JTable tblSujerencias;
    private javax.swing.JTable tblUsuarioMasCalificado;
    private javax.swing.JTable tblUsuarioMasCotizado;
    private javax.swing.JTable tblUsuarios;
    private javax.swing.JTextField txtComentario;
    private javax.swing.JTextField txtNombreUsuario;
    private javax.swing.JTextField txtVHU;
    // End of variables declaration//GEN-END:variables
}
